package com.tudulist.bo.impl;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Service;

import com.tudulist.bo.TodoListManager;
import com.tudulist.bo.UserManager;
import com.tudulist.dao.TodoListDao;
import com.tudulist.model.TodoList;
import com.tudulist.model.User;

@Service
public class TodoListManagerImpl implements TodoListManager {

	@Inject
	TodoListDao todoListDao;

	@Inject
	UserManager userManager;

	public TodoList createTodoList(TodoList todoList) {
		User user = userManager.getCurrentUser();
		todoList.setUser(user);
		return todoListDao.save(todoList);
	}

	public List<TodoList> findAll() {
		User user = userManager.getCurrentUser();
		return todoListDao.findAll(user);
	}

	public TodoList findById(Long todolistId) {
		return todoListDao.find(todolistId);
	}

}
